var jx = {
	getHTTPObject : function() {
		var http = false;
		if(typeof ActiveXObject != 'undefined') {
			try {http = new ActiveXObject("Msxml2.XMLHTTP");}
			catch (e) {
				try {http = new ActiveXObject("Microsoft.XMLHTTP");}
				catch (E) {http = false;}
			}
		} else if (window.XMLHttpRequest) {
			try {http = new XMLHttpRequest();}
			catch (e) {http = false;}
		}
		return http;
	},
	load : function (url,callback,format) {
		var http = this.init();
		if(!http||!url) return;
		if (http.overrideMimeType) http.overrideMimeType('text/xml');
		if(!format) var format = "text";
		format = format.toLowerCase();
		var now = "uid=" + new Date().getTime();
		url += (url.indexOf("?")+1) ? "&" : "?";
		url += now;
		http.open("GET", url, true);
		http.onreadystatechange = function () {
			if (http.readyState == 4) {
				if(http.status == 200) {
					var result = "";
					if(http.responseText) result = http.responseText;

					if(format.charAt(0) == "j") {
						result = result.replace(/[\n\r]/g,"");
						result = eval('('+result+')');
					}

					if(callback) callback(result);
				} else {
					if(error) error(http.status);
				}
			}
		}
		http.send(null);
	},
	init : function() {return this.getHTTPObject();}
}
var bindReady = function(handler){
    var called = false
    function ready() {
        if (called) return
        called = true
        handler()
    }
    if ( document.addEventListener ) {
        document.addEventListener( "DOMContentLoaded", function(){
            document.removeEventListener( "DOMContentLoaded", arguments.callee, false)
            ready()
        }, false )
    } else if ( document.attachEvent ) {
        if ( document.documentElement.doScroll && window == window.top ) {
            function tryScroll(){
                if (called) return
                try {
                    document.documentElement.doScroll("left")
                    ready()
                } catch(e) {
                    setTimeout(tryScroll, 0)
                }
            }
            tryScroll()
        }
        document.attachEvent("onreadystatechange", function(){
            if ( document.readyState === "complete" ) {
                document.detachEvent( "onreadystatechange", arguments.callee )
                ready()
            }
        })
    }
    if (window.addEventListener)
        window.addEventListener('load', ready, false)
    else if (window.attachEvent)
        window.attachEvent('onload', ready)
}
bindReady(function(){
    if(document.getElementsByTagName('h:service') != undefined){
        jx.load('http://hyho.ls/ajax/service/list', function(data){
            document.getElementsByTagName('h:service')[0].innerHTML = data;
        });
    }
    if(document.getElementsByTagName('h:suggest') != undefined){
        jx.load('http://hyho.ls/ajax/suggest/list', function(data){
            document.getElementsByTagName('h:suggest')[0].innerHTML = data;
        });
    }
});
